#ifndef PT100_LIB_H_
#define PT100_LIB_H_

#include "templib.h"
#include "dataproc.h"
#include "correct.h"

#ifdef __cplusplus
extern "C"
{
#endif

	typedef struct
	{
		float resistance; 
		int32_t adc_val;  
	} pt_sample_type;

	typedef struct
	{
		uint8_t err;		 
		uint8_t sample_nums; 
		uint8_t b_CF;

		i32_limit_type limit; 

		float filter;

		float coef; 

		pt_sample_type Sample[4]; 

		struct
		{
			float f_org; 
			float f_ctr;
			float f_real;
			float f_disp;
			int32_t i_ctr;
			int32_t i_disp;
			int32_t i_org;
		} result;

		struct
		{
			int32_t pb;
			int32_t pk;

			uint8_t point_len;
			void *point_list;
			
			float offset_before, offset_after;
		} correct;
	} pt_obj_type;

	float pt_cal_pbpk(pt_obj_type *pt, int32_t adc_val);

	float pt_cal_i16map(pt_obj_type *pt, int32_t adc_val);
	float pt_cal_i32map(pt_obj_type *pt, int32_t adc_val);
	float pt_cal_f32map(pt_obj_type *pt, int32_t adc_val);

	void pt_cal_reset(pt_obj_type *pt, int32_t result);

	float pt100_r2t(float f_res);
	float pt100_t2r(float f_temp);

	double pt100_r2t_d(double f_res);
	double pt100_t2r_d(double f_temp);

#ifdef __cplusplus
}
#endif

#endif 
